/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package utils;

import model.Queue;
import java.util.List;
import java.util.LinkedList;

/**
 *
 * @author wpc
 */
public class Utils {

    public static double exp_random(double mean) {
        return -mean * Math.log(1 - Math.random());
    }
    public static final double MEAN_LENGTH = 8e3;

    public static double length_random() {
        return exp_random(MEAN_LENGTH);
    }

    public static int[] steps(int... steps) {
        int[] result = new int[steps.length];
        for (int i = 0; i < result.length; ++i) {
            result[i] = steps[i];
        }
        return result;
    }

    public static int[] steps(Queue... queues) {
        int[] results = new int[queues.length];
        for (int i = 0; i < results.length; ++i) {
            results[i] = queues[i].getId();
        }
        return results;
    }

    public static String join(List<String> list, String s){
      StringBuffer sb = new StringBuffer();
      if(list.size()>=1){
        sb.append(list.get(0));
        for(int i=1;i<list.size();++i){
          sb.append(s);
          sb.append(list.get(i));
        }
      }
      return sb.toString();
    }

    public static String joinLong(List<Long> list, String s){
      List<String> l = new LinkedList<String>();
      for(Long i:list)
        l.add(Long.toString(i));
      return join(l,s);
    }

    public static String joinDouble(List<Double> list, String s){
      List<String> l = new LinkedList<String>();
      for(Double i:list)
        l.add(Double.toString(i));
      return join(l,s);
    }

    public static long G_SIZE = 12800000;
    public static long BATCH_SIZE = 5000;
    public static int K = 5;
    public static boolean ALL_BATCHES = false;
    public static boolean PRINT_QUEUE_DELAY = false;
}

